package com.bestv.bsr.core.service.impl.zt.remote;

import com.bestv.bsr.core.service.impl.zt.dto.ZTRequestParam;
import com.bestv.bsr.core.service.impl.zt.dto.ZTResponseDto;
import com.bestv.bsr.core.service.impl.zt.fallback.ZTFallbackHandler;
import com.bestv.remote.annotation.RemoteFunction;
import com.bestv.remote.annotation.RemoteParam;
import com.bestv.remote.annotation.RemoteService;
import com.bestv.remote.callback.CallbackHandler;
import com.bestv.remote.enums.ParamType;
import org.springframework.http.HttpMethod;
import org.springframework.validation.annotation.Validated;

/**
 * todo tracelog 中的 recommendcontext
 * <p>
 * bestv 中台服务
 *
 * @author taojiacheng
 */
@RemoteService(baseUrl = "${recommend.engine.baseurl}", targetServerName = "ZT")
@Validated
public interface ZTRemoteService {

    /**
     * 百视通 中台 推荐服务
     *
     * @param requestParam 请求参数
     * @param engineType   推荐类型
     * @return 推荐结果
     */
    @RemoteFunction(value = "/ott/api/rec/{engineType}", method = HttpMethod.POST,
            sentinelResource = "ZT", fallback = ZTFallbackHandler.class, block = ZTFallbackHandler.class)
    ZTResponseDto recommend(@RemoteParam(name = "requestParam", type = ParamType.JSON_BODY) ZTRequestParam requestParam,
                            @RemoteParam(name = "engineType", type = ParamType.PATH) String engineType);

    /**
     * 百视通 中台 推荐服务
     *
     * @param requestParam 请求参数
     * @param engineType   推荐类型
     * @return 推荐结果
     */
    @RemoteFunction(value = "/ott/api/rec/{engineType}", method = HttpMethod.POST,
            sentinelResource = "ZT", fallback = ZTFallbackHandler.class, block = ZTFallbackHandler.class)
    ZTResponseDto recommend(@RemoteParam(name = "requestParam", type = ParamType.JSON_BODY) ZTRequestParam requestParam,
                            @RemoteParam(name = "engineType", type = ParamType.PATH) String engineType,
                            @RemoteParam(name = "afterExecute", type = ParamType.AFTER_EXECUTE) CallbackHandler callbackHandler);
}
